//
//  ShangPinXiangQing_ViewController.m
//  OpenYooxi_IOS
//
//  Created by YeahYes on 15/3/19.
//  Copyright (c) 2015年 com.ivyvi.ee. All rights reserved.
//

#import "ShangPinXiangQing_ViewController.h"
#import "ShopXiangqingZhiDingTableViewCell.h"
#import "ShopPingLun_TableViewCell.h"

static NSString *identify = @"cell";
static NSString *identify1 = @"cell1";


@interface ShangPinXiangQing_ViewController ()

@end

@implementation ShangPinXiangQing_ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    _daohangView.backgroundColor = UIColorFromRGB(0xF8F8F8);
    
    _shangpinlabel.font = [UIFont boldSystemFontOfSize:16];
    
    
    
    _dabeijingView.backgroundColor = UIColorFromRGB(0xF1F2F6);
    _shangpinxiangqingtableview.backgroundColor = UIColorFromRGB(0xF1F2F6);

    
    _shangpinxiangqingtableview.dataSource = self;
    _shangpinxiangqingtableview.delegate = self;
    _shangpinxiangqingtableview.separatorStyle = UITableViewCellSeparatorStyleNone;
    _shangpinxiangqingtableview.backgroundColor = [UIColor clearColor];
    //取消tableview右侧的滑动条
    _shangpinxiangqingtableview.showsVerticalScrollIndicator = NO;

    
    UINib *nib = [UINib nibWithNibName:@"ShopXiangqingZhiDingTableViewCell" bundle:[NSBundle mainBundle]];
    [_shangpinxiangqingtableview registerNib:nib forCellReuseIdentifier:identify];
    
    UINib *nib1 = [UINib nibWithNibName:@"ShopPingLun_TableViewCell" bundle:[NSBundle mainBundle]];
    [_shangpinxiangqingtableview registerNib:nib1 forCellReuseIdentifier:identify1];
}




#pragma mark - UITableView delegate

//设置组头视图的高度
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    if (section==0) {
        return 0;
    }
    return 16;
}

#pragma mark - UITableView delegate 设置单元格高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if(indexPath.section == 0 && indexPath.row ==0){
        return 374;
    }else if (indexPath.section == 1 && indexPath.row ==0){
        return 88;
    }
    
    return 230;
}

//1.指定组的数量
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 5;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section ==0 && indexPath.row ==0) {
        ShopXiangqingZhiDingTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identify forIndexPath:indexPath];
        cell.backgroundColor = [UIColor whiteColor];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell;
    }
    
    ShopPingLun_TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identify1 forIndexPath:indexPath];
    cell.backgroundColor = [UIColor whiteColor];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

#pragma mark - 自定义组的头视图
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    
    UIView *headView = [[UIView alloc] initWithFrame:CGRectZero];
    headView.backgroundColor = [UIColor clearColor];
    return headView;
}

#pragma mark - 取消掉UITableView的选中状态

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
    
}



- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    CGFloat height = _shangpinxiangqingtableview.frame.size.height;
    CGFloat distanceFromButton = _shangpinxiangqingtableview.contentSize.height - _shangpinxiangqingtableview.contentOffset.y;
    if (distanceFromButton == height)
    {
        NSLog(@"=====滑动到底了");
    }
    
    if (_shangpinxiangqingtableview.contentOffset.y == 0)
    {
        NSLog(@"=====滑动到顶了");
    }
}




- (IBAction)fanhuibutton:(UIButton *)sender {
    
    //如果当前控制器的view是模态视图，则使用如下方法，关闭返回上一个界面
    [self dismissViewControllerAnimated:YES completion:NULL];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
